package com.lyn.xupdate;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import com.lyn.xupdate.databinding.ActivityMainBinding;
import com.lyn.xupdate.entity.UpdateEntity;
import com.lyn.xupdate.interfaces.CheckUpdateListener;
import com.lyn.xupdate.interfaces.DownloadListener;

public class MainActivity extends AppCompatActivity {

    private ActivityMainBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityMainBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
    }

    public void checkUpdate(View view) {
        XUpdate.getInstance().checkUpdate(new CheckUpdateListener() {
            @Override
            public void onCheckUpdateStart() {

            }

            @Override
            public void onCheckUpdateError(String error) {

            }

            @Override
            public void onCheckUpdateSuccess(UpdateEntity updateInfo) {

            }

            @Override
            public void onCheckUpdateEnd() {

            }
        });
    }

    public void download(View view) {
        XUpdate.getInstance().download("http://127.0.0.1:8080...", new DownloadListener() {
            @Override
            public void onDownloadStart() {

            }

            @Override
            public void onDownloadProgress(int progress) {

            }

            @Override
            public void onDownloadError(String error) {

            }

            @Override
            public void onDownloadSuccess(String path) {

            }

            @Override
            public void onDownloadEnd() {

            }
        });
    }
}